package data;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

public class ImageSet {
	private Float2 tileSize;
	private Float2 tileNumber;
	private BufferedImage set;
	
	public ImageSet (BufferedImage spriteSet, Float2 numberOfTiles)
	{
		set = spriteSet;
		tileNumber = numberOfTiles;
		tileSize = new Float2(
				set.getWidth() / getTileNumber().getF1(), 
				set.getHeight() / getTileNumber().getF2()
				);
	}
	
	public BufferedImage getTile (int x, int y)
	{
		BufferedImage output = new BufferedImage((int)tileSize.getF1(), (int)tileSize.getF2(), BufferedImage.TYPE_INT_ARGB);
		Graphics g = output.getGraphics();
		g.drawImage(set, 
				0, 0, output.getWidth(), output.getHeight(), 
				(int)tileSize.getF1() * x      , (int)tileSize.getF2() * y      , 
				(int)tileSize.getF1() * (x + 1), (int)tileSize.getF2() * (y + 1), 
				null);
		return output;
	}

	
	public Float2 getTileSize() {
		return tileSize;
	}
	public Float2 getTileNumber() {
		return tileNumber;
	}
}
